package com.apesource.project02.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @version 1.0
 * @auther:暮雪
 * @date:2025/10/7
 */
@Configuration
public class ElasticSearchConfig {
    public static final String MAPPING_TEMPLATE="{\n" +
            "    \"mappings\":{\n" +
            "        \"properties\":{\n" +
            "            \"messageId\":{\n" +
            "                \"type\":\"integer\",\n" +
            "                \"index\":\"true\"\n" +
            "            },\n" +
            "            \"userId\":{\n" +
            "                \"type\":\"integer\",\n" +
            "                \"index\":\"true\"\n" +
            "            },\n" +
            "            \"content\":{\n" +
            "                \"type\":\"text\",\n" +
            "                \"index\":\"true\"\n" +
            "            },\n" +
            "            \"seadTime\":{\n" +
            "                \"type\":\"date\",\n" +
            "                \"index\":\"true\"\n" +
            "            }\n" +
            "        }\n" +
            "    }\n" +
            "}";
    @Bean
    public RestHighLevelClient restHighLevelClient() {
        return new RestHighLevelClient(RestClient.builder(HttpHost.create("localhost:9200")));
    }

}
